package org.leiyang.domain.dtos;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.List;
import java.io.Serializable;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 客户端发送消息成功收到的通知请求
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MsgReceiveResp implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 消息ID（支持多条消息的成功接收通知）
     */
    private List<Long> msgIds;

    /**
     * 将{@link MsgReceiveResp}转化为{@link Map}
     */
    public static Map<String, String> convertToMap(MsgReceiveResp resp) {
        Map<String, String> msgMap = new HashMap<>(1);
        String msgIds = resp.getMsgIds().stream()
                .map(String::valueOf)
                .collect(Collectors.joining(","));
        msgMap.put("msgIds", msgIds);
        return msgMap;
    }


}